﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using Studio77.GuessLyric.Core;
using System.Windows.Threading;

namespace Studio77.GuessLyric.Pages
{
    public partial class NewUserPage : PhoneApplicationPage
    {
        public NewUserPage()
        {
            InitializeComponent();
        }

        private void btnReturn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// 在此处添加事件处理程序实现。
			if (this.NavigationService.CanGoBack)
            {
                this.NavigationService.GoBack();
            }
            else
            {
                this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }

        private void btnGet_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            SoundManager.PlayEffect(SoundManager.enter);
            MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
            marketplaceReviewTask.Show();
            StageManager.Instance.IsDoNewUserTask = true;

            //增加金币
            StageManager.Instance.TotalG += 3000;

            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += (object ss, EventArgs ee) =>
                {
                    timer.Stop();
                    this.btnGet.Content = "已领取";
                    this.btnGet.IsEnabled = false;
                    SoundManager.PlayEffect(SoundManager.coin);
                };
            timer.Start();

        }

    }
}